#include<bits/stdc++.h>
#define ll long long
#define MAXN 1000005
using namespace std;
struct node
{
    int vl,vr;
};
int T,cnt,ans,p[MAXN],pos[MAXN],vis[MAXN];
vector<node> vec;
bool check(int x)
{
    for(int i=0;i<vec.size();++i)
        if(vec[i].vl<=p[x]&&vec[i].vr>=p[x]&&vis[i]==0)return true;
    return false;
}
void dfs(int m,int dep,int last,int sum)
{
    if(sum>=ans)return;
    if(dep>cnt)
    {
        ans=sum;
        return;
    }
    for(int i=last+1;i<=m;++i)
    {
        if(check(i))
        {
            int nnn=0;
            vector<int> xxx;
            for(int j=0;j<vec.size();++j)
                if(vec[j].vl<=p[i]&&vec[j].vr>=p[i]&&vis[j]==0)
                    xxx.push_back(j),vis[j]=1,++nnn;
            dfs(m,dep+nnn,i,sum+1);
            for(int j=0;j<xxx.size();++j)
                vis[xxx[j]]=0;
        }
    }
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--)
    {
        int n,m,l,v;
        scanf("%d%d%d%d",&n,&m,&l,&v);
        for(int i=1;i<=n;++i)
        {
            int d,v0,a;
            scanf("%d%d%d",&d,&v0,&a);
            if(a==0)
            {
                if(v0>v)vec.push_back({d,l});
            }
            else if(a>0)
            {
                double t=((double)(v-v0))/a;
                double x=d+v0*t+0.5*a*t*t;
                if(x<=l)
                {
                    if(ceil(x)==x)vec.push_back({(int)ceil(x)+1,l});
                    else vec.push_back({(int)ceil(x),l});
                }
            }
            else
            {
                double t=((double)(v-v0))/a;
                double x=d+v0*t+0.5*a*t*t;
                if(x>0)
                {
                    if(x<=l)
                    {
                        if(floor(x)==x)vec.push_back({d,(int)floor(x)-1});
                        else vec.push_back({d,(int)floor(x)});
                    }
                    else vec.push_back({d,l});
                }
            }
        }
        for(int i=1;i<=m;++i)
        {
            scanf("%d",&p[i]);
            pos[p[i]]=1;
        }
        cnt=vec.size();
        for(int i=0;i<vec.size();++i)
        {
            vis[i]=1;
            for(int j=vec[i].vl;j<=vec[i].vr;++j)
            {
                if(pos[j])
                {
                    vis[i]=0;
                    break;
                }
            }
            if(vis[i])--cnt;
        }
        ans=m;
        dfs(m,1,0,0);
        printf("%d %d\n",cnt,m-ans);
        for(int i=1;i<=m;++i)pos[p[i]]=0;
        for(int i=0;i<=n;++i)vis[i]=0;
        vec.clear();
    }
    return 0;
}
